﻿import time

# 时间转 str
def date2str(d):
    s = time.strftime("%Y-%m-%d", d)
    return s
    
# 时间戳转换为时间
def tamp2date(timestamp):
    d = time.localtime(timestamp)
    return d

# str 转换时间戳
def str2date(t):
    d = time.mktime(time.strptime(t, "%Y-%m-%d"))
    return d

date = '2017-03-12'
if str2date(date) > time.time():
    time_struct = tamp2date(str2date(date)- 60*60*24*365)
    print time_struct


